﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Ext.Net;
using Sio.Mdm.Entities;
using Sio.Mdm.Client;
using Sio.Mdm.BF.Idm;
using Sio.Mdm.BF.Sifranti;
using Sio.Mdm.Types.Database;
using Sio.Mdm.Types;
using Sio.Mdm.BF.Ldap;
using System.Collections.Generic;
using System.Xml.Xsl;
using System.Xml;

namespace Sio.Mdm.Web.Organizacija
{
	public partial class PregledOsebje : Controls.Page
	{
		#region OnLoad
		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);
			NaloziSeznam();
		}
		#endregion

		#region Private
		private void NaloziSeznam()
		{
			int letoId = Request.GetValue<int>("letoid");

			EntityCollection<KadriPregled> col = new EntityCollection<KadriPregled>(
					new Filter<KadriPregled>()
			);
			this.StoreSplosniSeznam.DataSource = col;
			this.StoreSplosniSeznam.DataBind();

		}
		#endregion

		#region Export

		protected void IzvozVExcel(object sender, DirectEventArgs e)
		{
			string json = e.ExtraParams["gridExportData"].ToString();
			StoreSubmitDataEventArgs eSubmit = new StoreSubmitDataEventArgs(json, null);
			XmlNode xml = eSubmit.Xml;

			this.Response.Clear();
			this.Response.ContentType = "application/vnd.ms-excel";
			this.Response.AddHeader("Content-Disposition", "attachment; filename=PregledOsebja.xls");
			XslCompiledTransform xtExcel = new XslCompiledTransform();
			xtExcel.Load(Server.MapPath("PregledExcelSablona.xsl"));
			xtExcel.Transform(xml, null, this.Response.OutputStream);
			this.Response.End();
		}
		protected void IzvozVCSV(object sender, DirectEventArgs e)
		{
			string json = e.ExtraParams["gridExportData"].ToString();
			StoreSubmitDataEventArgs eSubmit = new StoreSubmitDataEventArgs(json, null);
			XmlNode xml = eSubmit.Xml;

			this.Response.Clear();
			this.Response.ContentType = "application/octet-stream";
			this.Response.AddHeader("Content-Disposition", "attachment; filename=PregledOsebja.csv");
			XslCompiledTransform xtCsv = new XslCompiledTransform();
			xtCsv.Load(Server.MapPath("PregledCsvSablona.xsl"));
			xtCsv.Transform(xml, null, this.Response.OutputStream);
			this.Response.End();
		}
		protected void IzvozVXML(object sender, DirectEventArgs e)
		{
			string json = e.ExtraParams["gridExportData"].ToString();
			StoreSubmitDataEventArgs eSubmit = new StoreSubmitDataEventArgs(json, null);
			XmlNode xml = eSubmit.Xml;
			string strXml = xml.OuterXml;

			this.Response.Clear();
			this.Response.AddHeader("Content-Disposition", "attachment; filename=PregledOsebja.xml");
			this.Response.AddHeader("Content-Length", strXml.Length.ToString());
			this.Response.ContentType = "application/xml";
			this.Response.Write(strXml);
			this.Response.End();
		}

		#endregion
	}
}
